﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    Layout = null;
}

<link href="~/lib/layui/css/layui.css" rel="stylesheet" />
<script src="~/lib/layui/layui.js"></script>
<script src="~/js/js.cookie.js"></script>
<script src="~/js/moment.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>
<!DOCTYPE html>
<html>
@* <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Demo</title>
    <!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
    <link href="//unpkg.com/layui@2.9.18/dist/css/layui.css" rel="stylesheet">
</head> *@
<body>
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <div class="layui-form-item">

                <div class="layui-form-item">
                    <button type="button" class="layui-btn layui-bg-red" lay-on="test-iframe-curl" onclick="Add()">保存</button>

                    <button type="button" class="layui-btn layui-bg-red" lay-on="test-iframe-curl">关闭</button>
                </div>

               

                <div class="layui-form-item">
                    <label class="layui-form-label">名称</label>
                    <div class="layui-input-inline layui-input-wrap">
                        <input type="text" name="roleName" value="" id="roleName" lay-verify="required" autocomplete="off" lay-reqtext="请输入用户名" lay-affix="clear" class="layui-input demo-phone">
                    </div>
                </div>


                <div class="layui-inline">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-inline layui-input-wrap">
                        <input type="text" name="roleDesc" value="" id="roleDesc" lay-verify="required" autocomplete="off" lay-reqtext="请输入用户名" lay-affix="clear" class="layui-input demo-phone">
                    </div>
                </div>


            </div>


        </div>
    </form>

    <!-- 请勿在项目正式环境中引用该 layui.js 地址 -->
    <script src="//unpkg.com/layui@2.9.18/dist/layui.js"></script>
    <script>
        layui.use(['table'], function () {
            var table = layui.table;
            var form = layui.form;

            // 创建渲染实例
            table.render({
                elem: '#ID-table-demo-templet',
                url: '/static/json/2/table/user.json', // 此处为静态模拟数据，实际使用时需换成真实接口
                page: true,
                height: '315px',
                cols: [[
                    { type: 'checkbox', fixed: 'left' },
                    // 未自定义模板的普通列
                    { field: 'id', fixed: 'left', width: 120, title: '功能' },
                    // 模板 - 选择器写法
                    { field: 'username', width: 300, title: '操作' },

                ]]
            });


            table.render({
                elem: '#ID-table-demo-templet1',
                url: '/static/json/2/table/user.json', // 此处为静态模拟数据，实际使用时需换成真实接口
                page: true,
                height: '315px',
                cols: [[
                    { type: 'checkbox', fixed: 'left' },
                    // 未自定义模板的普通列
                    { field: 'id', fixed: 'left', width: 120, title: '角色名称' },

                ]]
            });
        });
    </script>
</body>

</html>

<script>
      function Add()
      {
        var roleName = $("#roleName").val();
        var roleDesc = $("#roleDesc").val();
                $.ajax({
            url: "http://localhost:5123/api/UsersInterface/AddRole",
                    type:'post',
                    data: JSON.stringify({ roleName: roleName, roleDesc: roleDesc }),
                    dataType: "json",
                    contentType: "application/json",
                    success: res => {
                        if (res.data==0) {
                    layer.msg(res.msg);
                        }
                        else {
                    layer.msg(res.msg);
                        }
                    }
                })
            }
</script>